package com.nf.xiaomi.web.controller;

import com.nf.mvc.ViewResult;
import com.nf.mvc.mapping.RequestMapping;
import com.nf.mvc.support.ResponseVO;
import com.nf.xiaomi.entity.EvaluateEntity;
import com.nf.xiaomi.service.EvaluateService;
import com.nf.xiaomi.service.impl.EvaluateServiceImpl;
import com.nf.xiaomi.util.JsonUtils;

import java.time.LocalDateTime;
import java.util.List;

import static com.nf.mvc.handler.HandlerHelper.json;

@RequestMapping("/evaluate")
public class EvaluateController {
    EvaluateService service = new EvaluateServiceImpl();
    @RequestMapping("/getAll")
    public ViewResult getAll() {
        List<EvaluateEntity> list = service.getAll();
        return json(new ResponseVO(200, "ok", list));
    }
    @RequestMapping("/getAllUserID")
    public ViewResult getAllUserID(Long account) {
        List<EvaluateEntity> list = service.getAll(account);
        return json(new ResponseVO(200, "ok", list));
    }
    @RequestMapping("/getEvaluateID")
    public ViewResult getEvaluateID(Integer evaluateId) {
        List<EvaluateEntity> list = service.getAll(evaluateId);
        return json(new ResponseVO(200, "ok", list));
    }
    @RequestMapping("/insert")
    public ViewResult insert(Integer orderDetailsId,String evaluateContent, LocalDateTime evaluateDate, Integer nstate) {
        int insert = service.insert(orderDetailsId,evaluateContent, evaluateDate, nstate);
        return JsonUtils.Result(insert);
    }
    @RequestMapping("/update")
    public ViewResult update(String evaluateContent, LocalDateTime evaluateDate, Integer evaluateId) {
        int update = service.update(evaluateContent, evaluateDate, evaluateId);
        return JsonUtils.Result(update);
    }
    @RequestMapping("/delete")
    public ViewResult delete(Integer evaluateId) {
        int delete = service.delete(evaluateId);
        return JsonUtils.Result(delete);
    }
}
